<?php

namespace Topxia\Service\TiXing\Dao\Impl;

use Topxia\Service\Common\BaseDao;
use Topxia\Service\TiXing\Dao\TiXingDao;

class TiXingDaoImpl extends BaseDao implements TiXingDao
{   
    //获取题型的信息并分页
    public function get($start, $limit)
    {
        $this->filterStartLimit($start, $limit);
        $sql = "SELECT * FROM question_type LIMIT {$start},{$limit}";
        return $this->getConnection()->fetchAll($sql);

    }

    //获取题型的总数
    public function total()
    {
        $sql = " SELECT count('id') FROM question_type";
        return $this->getConnection()->fetchAll($sql);
    }


    //添加题型
     public function insert($ptype,$name,$title)
     {
        return $this->getConnection()->exec("insert into question_type(name,title,ptype)values('$name','$title','$ptype')");
     }

     //删除题型

     public function delete($pid)
     {
        return $this->getConnection()->exec("delete  from question_type where pid=".$pid);
     }
}